package com.example.controller;

import com.example.entity.Employee;
import com.example.entity.LoginInfo;
import com.example.service.EmployeeService;
import com.example.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoginController {
    @Autowired
    private EmployeeService employeeService;
    @PostMapping("/login")
    public Result login(@RequestBody Employee employee) {
        log.info("员工登录：{}", employee);
        LoginInfo loginInfo = employeeService.login(employee);
        if (loginInfo != null) {
            return Result.success(loginInfo);
        }
        return Result.error("用户名或密码输入错误！");
    }
}